#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#define FOR(i,a,n) for(int i=a,_n(n);i<_n;++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int GetAns(string &s)
{
	char pre = s[0];
	int cnt = 0;
	int ans = 0;
	s += 'e';
	REP(i,s.size())
	{
		if(cnt>=5||pre!=s[i])
		{
			cnt = 1;
			++ans;
			pre = s[i];
			continue;
		}
		++cnt;
		pre = s[i];
	}
	return ans;
}

int main()
{
	string item;
	while(cin>>item)
	{
		cout<<GetAns(item)<<endl;
	}
	return 0;
}
